
$(function() {
	
    var $lessons = $('#lessons_block');
    
   
    $("#lessons_menu").buildMenu(
    	      {
    	        menuWidth:170,
    	        openOnRight:true,
    	        menuSelector: ".menuContainer",
    	        iconPath:"images/ico/",
    	        hasImages:true,
    	        fadeInTime:200,
    	        fadeOutTime:200,
    	        adjustLeft:0,
    	        adjustTop:0,
    	        opacity:.95,
    	        openOnClick:false,
    	        minZindex:200,
    	        shadow:true,
    	        hoverIntent:300,
    	        submenuHoverIntent:500,
    	        closeOnMouseOut:true,
    	        closeAfter:1000
    	      });
    
    $("#lesson_editor").hide();

    $("#new_lesson").click(function(calEvent, $event) {
            var $dialogContent = $("#lesson_editor");
            resetForm($dialogContent);
            var titleField = $dialogContent.find("input[name='title']");
            var subjectsField = $dialogContent.find("input[name='subjects']");
            var objectiveField = $dialogContent.find("input[name='objective']");
            var resourcesField = $dialogContent.find("input[name='resources']");
            
           
            
            $dialogContent.dialog({
                modal: true,
                title: "New Lesson",
                close: function() {
                   $dialogContent.dialog("destroy");
                   $dialogContent.hide();
                },
                buttons: {
                    save : function(){
                        

                        $dialogContent.dialog("close");
                    },
                    cancel : function(){
                        $dialogContent.dialog("close");
                    }
                }
            }).show();
             
           $(window).resize(); //fixes a bug in modal overlay size ??
            
            
		});
		
    
    function resetForm($dialogContent) {
         $dialogContent.find("input").val("");
         $dialogContent.find("textarea").val("");
         $dialogContent.find("input").attr('checked', null);
    }
    
   
    
    
    

  

});